# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
# SPDX-License-Identifier: MIT

import logging
import os
import uuid

from langchain.schema import HumanMessage, SystemMessage

from src.config.agents import AGENT_LLM_MAP
from src.llms.llm import get_llm_by_type
from src.prompts.template import get_prompt_template

from .state import HtmlState

logger = logging.getLogger(__name__)


def html_composer_node(state: HtmlState):
    logger.info("Generating html content...")
    model = get_llm_by_type(AGENT_LLM_MAP["html_composer"])
    html_content = model.invoke(
        [
            SystemMessage(content=get_prompt_template(f"{state["agent_code"]}/html")),
            HumanMessage(content=state["input"]),
        ],
    )
    logger.info(f"html_content: {html_content}")
    return {"output": html_content.content}
